use std::sync::{Arc, Mutex};

use model_graph_types::container::workflow::{
    ScriptStatement, WorkflowBlockExecuteResult, WorkflowScriptLanguage,
};

use crate::workflow::context::WorkflowContext;

pub async fn execute(
    statement: &ScriptStatement,
    context: Arc<Mutex<WorkflowContext>>,
) -> anyhow::Result<WorkflowBlockExecuteResult> {
    //

    let language = &statement.language;

    tracing::debug!("执行[{:?}]脚本.", language);
    //
    match language {
        WorkflowScriptLanguage::JavaScript => {
            return super::javascript::execute(statement, context).await;
        }
        _ => {}
    }

    Ok(WorkflowBlockExecuteResult::succeed())
}
